/*-----------------------------------------------------------------------------
Archivo:      test_cu.c
Autor:	      Cesar Armando Fuguet Tortolero
	          Debe compilarse con la herramienta genpat.
------------------------------------------------------------------------------*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
    char* str;
    str = (char *) mbkalloc (32 * sizeof(char));
    sprintf(str,"%d",entier);
    return(str);
}

main() {

    DEF_GENPAT("test_cu");

    DECLAR("VA_i"           ,":2","B", IN   ,	"1 downto 0"  , "");
    DECLAR("VB_i"           ,":2","B", IN   ,	"1 downto 0"  , "");
    DECLAR("VD_i"           ,":2","B", IN   ,	"1 downto 0"  , "");
    DECLAR("OPCODE_i"       ,":2","B", IN   ,	"3 downto 0"  , "");
    DECLAR("HAZARD_i"       ,":2","B", IN   ,	      ""      , "");
    DECLAR("CLK_i"          ,":2","B", IN   ,	      ""      , "");
    DECLAR("RESET_i"        ,":2","B", IN   ,	      ""      , "");
    DECLAR("IDXI_o"         ,":2","B", OUT  ,	"3 downto 0"  , "");
    DECLAR("IDXJ_o"         ,":2","B", OUT  ,	"3 downto 0"  , "");
    DECLAR("IDXK_o"         ,":2","B", OUT  ,	"3 downto 0"  , "");
    DECLAR("ALU_OP_o"       ,":2","B", OUT  ,	"3 downto 0"  , "");
    DECLAR("INSTR_FETCH_o"  ,":2","B", OUT  ,	      ""      , "");
    DECLAR("WE_o"           ,":2","B", OUT  ,	      ""      , "");
    DECLAR("VDD"            ,":2","B", IN   ,	      ""      , "");
    DECLAR("VSS"            ,":2","B", IN   ,	      ""      , "");

    DECLAR("fft_stg_wire",
            ":2",
            "B",
            SIGNAL,
            "2 downto 0",
            "");

    DECLAR("hazard_fsm_wire",
            ":2",
            "B",
            SIGNAL,
            "",
            "");

    DECLAR("counter_wire",
           ":2",
           "B",
           SIGNAL,
           "1 downto 0",
           "");

    LABEL("cu");

    SETTUNIT("ns");
    AFFECT("0", "VDD"	    , "1"       ); 
    AFFECT("0", "VSS"	    , "0"       );
    AFFECT("0", "CLK_i"	    , "1"       );
    AFFECT("0", "RESET_i"   , "1"       );
    AFFECT("0", "HAZARD_i"  , "0"       );
    AFFECT("0", "OPCODE_i"	, "0b1111"  );
    AFFECT("0", "VA_i"	    , "0b00"    );
    AFFECT("0", "VB_i"	    , "0b01"    );
    AFFECT("0", "VD_i"	    , "0b10"    );

    AFFECT("50", "CLK_i"	   , "0"      );
    AFFECT("100", "CLK_i"	   , "1"      );
    AFFECT("100", "RESET_i"    , "0"      );

    int i;
    for(i=1; i<36; i++) {
        AFFECT("+50"    , "CLK_i"   , inttostr(i%2));
    }

    AFFECT("+0", "HAZARD_i"  , "1"       );

    for(i=1; i<8; i++) {
        AFFECT("+50"    , "CLK_i"   , inttostr(i%2));
    }

    AFFECT("+0", "HAZARD_i"  , "0"       );

    for(i=1; i<8; i++) {
        AFFECT("+50"    , "CLK_i"   , inttostr(i%2));
    }

    SAV_GENPAT();

    exit(0);
}

/* vim: tabstop=4 : expandtab : shiftwidth=4
*/
